package coop.bancocredicoop.proyectos.gd.query;

import org.hibernate.classic.Session;
import org.hibernate.Transaction;

import coop.bancocredicoop.proyectos.gd.hibernate.HibernateUtil;

public class DataService {

	public Session getSession() {
		return HibernateUtil.getSessionFactory().openSession();
	}
	
	public void closeSession(Session session) {
		if (session != null && session.isOpen()) {
            session.close();
        }
	}
	
	public void rollback(Transaction tx) {
		if (tx!=null) {
			tx.rollback();
		}
	}
	
	public Transaction beginTransaction(Session session) {
		return session.beginTransaction();
	}
	
	public void commit(Transaction tx) {
		tx.commit();
	}
	
}
